<?php

define('IN_MEDIA',true);
include('includes/config.php');
include('includes/functions.php');

$web_description = "Dance Music";
$limit = '10'; // Số lượng media trong RSS


$web_name = m_get_config('web_title');
$web_url = m_get_config('web_url');
$admin_email = m_get_config('web_email');
$last_built = date('D, d M Y H:i:s O');
$copy_year = "COPYRIGHT".date("Y");

echo '<?xml version="1.0" encoding="utf-8"?>';
echo "\n<rss version=\"2.0\">\n";
echo "<channel>\n";
echo "	<title>$web_name</title>\n";
echo "	<link>$web_url</link>\n";
echo "	<description>$web_description</description>\n";
echo "	<copyright>$copy_year (C) $web_name</copyright>\n";
echo "	<generator>$web_name</generator>\n";
echo "	<language>vi-vn</language>\n";
echo "	<lastBuildDate>$last_built</lastBuildDate>\n";
echo "	<managingEditor> $admin_email </managingEditor>\n";
echo "	<webMaster> $admin_email </webMaster>\n";
echo "	<ttl>60</ttl>\n\n";
echo "	<image>\n";
echo "		<title>$web_name</title>\n";
echo "		<url>".$web_url."/mixvn_cover.png</url>\n"; // đặt link logo tại đây
echo "		<link>$web_url</link>\n";
echo "		<width>144</width>\n";
echo "		<height>144</height>\n";
echo "		<description>$web_name</description>\n";
echo "	</image>\n\n";

$fields = "m_id, m_title, m_type, m_time, m_viewed_month";
$q = "SELECT ".$fields." FROM ".$tb_prefix."data ORDER BY m_viewed_month DESC LIMIT ".$limit." ";

if ($q) $q = $mysql->query($q);
if ($mysql->num_rows($q)) {
	while ($r = $mysql->fetch_array($q)) {
		$m_id = $r['m_id'];

		//date_default_timezone_set('GMT');
		$m_time = date('D, d M Y H:i:s O', $r['m_time']);
		if ($r['m_time'] =='0') $m_time = 'Tuesday, July 28, 2010 8:12 PM';

		switch ($r['m_type']) {
			case 1 : $media_type = 'Music'; break;
			case 2 : $media_type = 'Flash'; break;
			case 3 : $media_type = 'Movie'; break;
		}
		$m_link = url_link($m_id,$r['m_title'],'nhac-san');

		echo "		<item>\n"; 
		echo "			<title>".strip_tags($r['m_title'])."</title>\n"; 
		echo "			<link>".$m_link."</link>\n"; 
		echo "			<description>"."Số lần nghe trong tháng: ".$r['m_viewed_month']."</description>\n"; 
		echo "			<guid>".$m_link."</guid>\n"; 
		echo "			<pubDate>".$m_time."</pubDate>\n"; 
		echo "		</item>\n";
	}
}
else echo " ";

echo "	</channel>\n\n"; 
echo "</rss>";
?>